package com.windowes.weichang.controller.platform;

import com.windowes.weichang.access.AccessLimit;
import com.windowes.weichang.common.ServerResponse;
import com.windowes.weichang.pojo.DemandTalk;
import com.windowes.weichang.service.DemandService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/***
 *
 * @author: yangqing
 * @email: qing.yang@bangdao-tech.com
 * @createTime: 2018/7/17 下午7:15
 * @description:
 *
 **/
@RestController
@RequestMapping("comment")
public class CommentController {

    @Autowired
    DemandService demandService;

    @AccessLimit
    @GetMapping("list")
    public ServerResponse list(@RequestParam(value = "pageNo", defaultValue = "1") int pageNo,
                               @RequestParam(value = "pageSize", defaultValue = "15") int pageSize) {
        return demandService.commentList(pageNo, pageSize);
    }

    @AccessLimit(shopUser = true)
    @GetMapping("listForShop")
    public ServerResponse listForShop(@Param("type") String type, @Param("keyword") String keyword, @RequestParam(value = "pageNo", defaultValue = "1") int pageNo,
                                      @RequestParam(value = "pageSize", defaultValue = "15") int pageSize) {
        return demandService.commentListForShop(type,keyword, pageNo, pageSize);
    }


    @AccessLimit
    @PostMapping("commentForCustomer")
    public ServerResponse commentForCustomer(@RequestBody DemandTalk demandTalk) {
        return demandService.commentForCustomer(demandTalk);
    }
    @AccessLimit(shopUser = true)
    @PostMapping("commentForShop")
    public ServerResponse commentForShop(@RequestBody DemandTalk demandTalk) {
        return demandService.commentForShop(demandTalk);
    }

    @AccessLimit
    @PostMapping("commentForMange")
    public ServerResponse commentForManage(@RequestBody DemandTalk demandTalk) {
        return demandService.commentForManage(demandTalk);
    }

}
